﻿// Copyright (c) Inossem. All rights reserved.
// Licensed under the LGPL-3.0 license. See LICENSE file in the project root for full license information.
using DWF.Studio.Share.Serialization;
using System;
using System.Activities.Tracking;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DWF.Studio.ScriptEngine.IPC.WorkFlow
{
    /// <summary>
    /// 工作流单步信息
    /// </summary>
    [Serializable]
    public class WorkflowFrameInfo : FrameInfoBase
    {
        /// <summary>
        /// 活动信息
        /// </summary>
        public WorkflowStepInfo Activity { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public string State { get; set; }

        /// <summary>
        /// 变量集合
        /// </summary>
        public IEnumerable<VariableInfo> Variables { get; set; }

        /// <summary>
        /// 参数集合
        /// </summary>
        public IEnumerable<ArgumentInfo> Arguments { get; set; }

        /// <summary>
        /// 时间时间
        /// </summary>
        public DateTime EventTime { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public WorkflowFrameInfo()
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="record"></param>
        /// <param name="variables"></param>
        /// <param name="arguments"></param>
        public WorkflowFrameInfo(ActivityStateRecord record, List<VariableInfo> variables, List<ArgumentInfo> arguments)
        {
            this.Activity = new WorkflowStepInfo() { Id = record.Activity.Id, Name = record.Activity.Name, TypeName = record.Activity.TypeName };
            this.State = record.State;
            this.EventTime = record.EventTime;
            this.Variables = variables;
            this.Arguments = arguments;
        }

        public WorkflowFrameInfo(ActivityScheduledRecord record, List<VariableInfo> variables, List<ArgumentInfo> arguments)
        {
            this.Activity = new WorkflowStepInfo() { Id = record.Child.Id, Name = record.Child.Name, TypeName = record.Child.TypeName };
            this.EventTime = record.EventTime;
            this.Variables = variables;
            this.Arguments = arguments;
        }
    }
}
